package com.kfm.student.service.impl;

import com.kfm.student.domain.User;
import com.kfm.student.mapper.UserMapper;
import com.kfm.student.service.UserService;
import com.kfm.student.util.MD5Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper mapper;


    @Override
    public User login(User user) {
        if (ObjectUtils.isEmpty(user)){

        }
        user.setPassword(MD5Util.encode(user.getPassword()));
        List<User> users = mapper.selectAll(user);
        return users.size() > 0 ? users.get(0) : null;
    }
}
